package excp;

class ExTest8 {
	public static void main(String args[]) throws Exception{
		Service serv=new Service();
		Student st=null;
		try{
			st=serv.searchStudent(98);
			System.out.println(st);
		}catch (Exception e) {
			e.printStackTrace();
		}
		st=serv.searchStudent(99);
		System.out.println("\n"+st+"\n");
		st=serv.searchStudent(84);
		System.out.println(st);
		System.out.println("--Main End--");
	}
}
class Service{
	Student searchStudent(int id) throws IdNotFoundException{
		Student st=null;
		if(id==99){
			st=new Student(99,"sri",31903290);
		}
		else{
			throw new IdNotFoundException(id);
		}
		return st;
	}
}
class IdNotFoundException extends Exception{
	private int id;
	IdNotFoundException(int id) {
		this.id=id;
	}
	public String toString(){
		return this.getClass().getName()+":"+getMessage();
	}
	public String getMessage(){
		return "Id "+id;
	}
}
class Student{
	int sid;
	String name;
	long phone;
	Student(int sid,String name,long phone) {
		this.sid=sid;
		this.name=name;
		this.phone=phone;
	}
	public String toString(){
		return sid+"\t"+name+"\t"+phone;
	}
}